package com.treasure.mall.zbqmallapi.mapstruct;

import com.treasure.mall.biz.entity.embeddable.GoodsInfo;
import com.treasure.mall.biz.entity.order.AfterSaleBillPO;
import com.treasure.mall.biz.entity.order.OrderItemPO;
import com.treasure.mall.biz.entity.order.SubOrderPO;
import com.treasure.mall.zbqmallapi.vo.order.AfterSaleBillVO;
import com.treasure.mall.zbqmallapi.vo.order.OrderItemVO;
import com.treasure.mall.zbqmallapi.vo.order.SubOrderVO;
import com.treasure.mall.zbqmallapi.vo.product.GoodsInfoVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.zbqmallapi.mapstruct
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/6/15 22:26
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * Copyright 2019-2022 com.treasure.mall.zbqmallapi.mapstruct Inc. All rights reserved.
 */
@Mapper
public interface OrderMapStruct {

    OrderMapStruct Instance = Mappers.getMapper(OrderMapStruct.class);

    @Mappings({
            @Mapping(target = "orderItem", source = "orderItemPOS"),
            @Mapping(target = "merchantId", source = "merchantPO.merchantId"),
            @Mapping(target = "merchantTitle", source = "merchantPO.data.title"),
            @Mapping(target = "merchantLogo", source = "merchantPO.data.avatar"),
            @Mapping(target = "dealOrderId", source = "orderPO.orderId"),
            @Mapping(target = "receivingInfo", source = "orderPO.receivingInfo"),
            @Mapping(target = "returnedPurchase", source = "merchantPO.data.returnedPurchase"),
            @Mapping(target = "payExpireTime", source = "orderPO.payExpireTime"),
            @Mapping(target = "payTime", source = "orderPO.payTime"),
            @Mapping(target = "payStatus", source = "orderPO.payStatus"),
            @Mapping(target = "surplusAmount", source = "orderPO.surplusAmount"),
            @Mapping(target = "userOrderStatus", expression = "java(po.userOrderStatus())"),
            @Mapping(target = "refundAmount", expression = "java(po.refundTotalAmount())"),
            @Mapping(target = "afterSaleStatus", expression = "java(po.getOrderItemPOS().get(0).getAfterSaleStatus())"),
            @Mapping(target = "afterSaleFinishTime", expression = "java(po.getOrderItemPOS().get(0).getAfterSaleFinishTime())"),
            @Mapping(target = "balance", source = "orderPO.balance"),
            @Mapping(target = "enableContact", source = "merchantPO.enableContact")
    })
    SubOrderVO suOrderPO2SuOrderVO(SubOrderPO po);


    List<SubOrderVO> suOrderPO2SuOrderVOS(List<SubOrderPO> pos);

    OrderItemVO orderItemPo2OrderItemVo(OrderItemPO po);

    List<OrderItemVO> orderItemPo2OrderItemVos(List<OrderItemPO> pos);

    GoodsInfoVO goodsInfo2GoodsInfoVo(GoodsInfo goodsInfo);

    @Mappings({
            @Mapping(target = "merchantId", source = "merchantPO.merchantId"),
            @Mapping(target = "merchantTitle", source = "merchantPO.data.title"),
            @Mapping(target = "merchantLogo", source = "merchantPO.data.avatar")
    })
    AfterSaleBillVO po2AfterSaleBillVO(AfterSaleBillPO po);

    List<AfterSaleBillVO> po2AfterSaleBillVOS(List<AfterSaleBillPO> pos);
}
